package com.mrdeer.common.entity.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.mrdeer.common.base.Converter;
import com.mrdeer.common.entity.beans.PageEntity;
import com.mrdeer.common.entity.sys.Department;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class DepartmentDTO extends Department implements Converter<Department, DepartmentDTO> {

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private PageEntity page;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private List<String> ids;

    @Override
    public void convert2Do(Department department) {
        BeanUtils.copyProperties(this, department);
    }

    @Override
    public DepartmentDTO convert(Department department) {
        BeanUtils.copyProperties(department, this);
        return this;
    }
}
